import { sys } from "typescript";
import { BitmapObj, Move, GameEngine } from "./engine";

const engine = new GameEngine();
const sceneConfig = [
    { type: 'bitmap', id: 'charactor', properties: { x: 100, y: 240, source: 'assets/cloud.png' } },
    { type: 'rectangle', properties: { x: 140, y: 35, width: 150, height: 20, color: 'red' } },
    { type: 'rectangle', properties: { x: 140, y: 65, width: 130, height: 20, color: 'blue' } },
    { type: 'rectangle', properties: { x: 140, y: 90, width: 160, height: 20, color: 'green' } },
    { type: 'bitmap', properties: { x: 0, y: 10, source: 'assets/status.png' } },
    { type: 'bitmap', properties: { x: 0, y: 10, source: 'assets/que.png' } },
    { type: 'bitmap', properties: { x: 0, y: 10, source: 'assets/bars.png' } },
    { type: 'rectangle', properties: { x: 410, y: 230, width: 600, height: 3, color: 'black' } },
    { type: 'rectangle', properties: { x: 410, y: 120, width: 600, height: 3, color: 'black' } },
    { type: 'textfield', properties: { x: 430, y: 190, color: 'black', text: '摸 之 古 城', font: '100px 宋体' } },

    { type: 'bitmap', properties: { x: 100, y: 370, source: 'assets/slot.png' } },
    { type: 'bitmap', properties: { x: 100, y: 370, source: 'assets/magic.png' } },
    { type: 'textfield', properties: { x: 160, y: 440, color: 'black', text: '摸法', font: '20px 宋体' } },

    { type: 'bitmap', properties: { x: 190, y: 450, source: 'assets/slot.png' } },
    { type: 'bitmap', properties: { x: 190, y: 450, source: 'assets/darksword.png' } },
    { type: 'textfield', properties: { x: 220, y: 510, color: 'black', text: '黑暗剑+22', font: '20px 宋体' } },

    { type: 'bitmap', properties: { x: 10, y: 450, source: 'assets/slot.png' } },
    { type: 'bitmap', properties: { x: 10, y: 450, source: 'assets/shild.png' } },
    { type: 'textfield', properties: { x: 60, y: 520, color: 'black', text: '丢人盾', font: '20px 宋体' } },

    { type: 'bitmap', properties: { x: 100, y: 530, source: 'assets/slot.png' } },
    { type: 'bitmap', properties: { x: 100, y: 530, source: 'assets/cola.png' } },
    { type: 'textfield', properties: { x: 150, y: 770, color: 'black', text: '冰阔落', font: '20px 宋体' } },
    { type: 'textfield', properties: { x: 190, y: 740, color: 'black', text: '5', font: '20px 宋体' } },

    { type: 'rectangle', properties: { x: 1200, y: 750, width: 200, height: 3, color: 'black' } },
    { type: 'rectangle', properties: { x: 1200, y: 780, width: 200, height: 3, color: 'black' } },
    { type: 'textfield', properties: { x: 1250, y: 753, color: 'black', text: '114514 香香鸡', font: '20px 宋体' } },
]

engine.start(['assets/cloud.png', 'assets/status.png', 'assets/que.png', 'assets/bars.png', 'assets/slot.png'
    , 'assets/shild.png', 'assets/darksword.png', 'assets/cola.png', 'assets/magic.png'], sceneConfig);
engine.onUpdate = (duringTime) => {
    const speed = 60;
    const charBitmap = engine.getRenderObj('charactor') as BitmapObj;
    const charmove = new Move(charBitmap, 60);
    charmove.update(duringTime);
}
